<?php

namespace app\admin\model\chase;

use think\Model;
use traits\model\SoftDelete;

class Parents extends Model
{

    use SoftDelete;
    protected $hidden = [];
    

    // 表名
    protected $table = 'parents';
    
    // 自动写入时间戳字段
    protected $autoWriteTimestamp = 'int';

    // 定义时间戳字段名
    protected $createTime = 'createtime';
    protected $updateTime = 'updatetime';
    protected $deleteTime = 'deletetime';

    // 追加属性
    protected $append = [

    ];
    

    public function students()
    {
        return $this->belongsToMany(Student::class, 'parent_students', 'student_id', 'parent_id');
    }

    public function relations()
    {
        return $this->hasOne(Relations::class, 'id', 'relation_id');
    }
    
    public static function getByPhone($phone)
    {
        return self::where('phone', $phone)->find();
    }




}
